package com.sleepcamel.resteasyConfigurator.view;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;

import com.sleepcamel.rest.domain.BaseMethod;
import com.sleepcamel.rest.domain.method.NonRESTMethod;
import com.sleepcamel.rest.domain.method.RESTMethod;
import com.sleepcamel.rest.domain.method.parameter.MethodParameter;
import com.sleepcamel.resteasyConfigurator.view.detail.DetailView;
import com.sleepcamel.resteasyConfigurator.view.detail.NonRESTMethodDetailView;
import com.sleepcamel.resteasyConfigurator.view.detail.RESTMethodDetailView;
import com.sleepcamel.resteasyConfigurator.view.sourcecode.SourceCodeView;

public class MethodDetailSourceCodeComposite<T extends BaseMethod<MethodParameter>> extends DetailSourceCodeComposite<T>{

	public MethodDetailSourceCodeComposite(Composite parent, int style) {
		super(parent, style);
	}

	@SuppressWarnings("unchecked")
	public void setModelData(T data) {
		DetailView<T> detailView = null;
		if ( data instanceof RESTMethod)
			detailView = (DetailView<T>) new RESTMethodDetailView(this, SWT.NONE);
		
		if ( data instanceof NonRESTMethod)
			detailView = (DetailView<T>) new NonRESTMethodDetailView(this, SWT.NONE);

		if ( detailView != null ){
			detailView.setModelData(data);
			SourceCodeView sourceCodeView = new SourceCodeView(this, SWT.NONE);
			sourceCodeView.setData(data);
			setViews(detailView, sourceCodeView);
		}
	}
	
}
